package exercises.leetcode;

import java.util.TreeMap;

/**
 * <a href="">
 * </a>
 *
 * <p><span color="#87CEEB">描述:</span>
 *
 * @author or2
 * @date 2021年10月17日 时间: 11:15
 */
public class No5904 {
    private TreeMap<Integer, Integer> res = new TreeMap<>();

    public int countMaxOrSubsets(int[] nums) {
        dfs(nums, 0, 0);

        return res.lastEntry().getValue();
    }

    private void dfs(int[] nums, int start, int cur_val) {
        if (start == nums.length) {
            res.put(cur_val, res.getOrDefault(cur_val, 0) + 1);
            return;
        }

        dfs(nums, start + 1, cur_val);
        dfs(nums, start + 1, cur_val | nums[start]);
    }
}
